package com.enjoy.merger;

import com.alibaba.dubbo.rpc.cluster.Merger;

/**
 * <p>TODO</p>
 *
 * @Author Ellison Pei
 * @Date 2021/7/16 15:13
 **/
public class StringMerger implements Merger<String> {
    /**
     *  定义group实现类的返回值  针对String类型的合并规则
     * @param strings
     * @return
     */
    @Override
    public String merge(String... strings) {
        if (strings.length == 0) {
            return null;
        }
        StringBuilder builder = new StringBuilder();
        for (String s : strings) {
            if (s != null){
                builder.append(s).append("-");
            }
        }
        return builder.toString();
    }
}
